package com.neusoft.nep.NEPG.controller;

import com.neusoft.nep.entity.Gridder;
import com.neusoft.nep.entity.nepsFeedback;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;

import java.io.IOException;

public class CardViewController {
    @FXML
    private Label level;
    @FXML
    private Button getIn;
    @FXML
    private Label address;
    @FXML
    private Label LocationAndTimes;

    private Gridder gridder;

    private nepsFeedback feedback;

    public void setData(nepsFeedback feedbacks, Gridder gridder) {
        feedback = feedbacks;
        this.level.setText(feedback.getLevel());
        this.address.setText(feedback.getAddress());
        this.LocationAndTimes.setText( feedback.getProvince() + " " + feedback.getCity() + " " + feedback.getDate());
        this.gridder = gridder;
    }

    @FXML
    public void getIn() {
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("../view/FeedbackInfoView.fxml"));
            Parent root = loader.load();
            Stage stage = (Stage) getIn.getScene().getRoot().getScene().getWindow();
            Scene scene = new Scene(root);

            FeedbackInfoViewController controller = (FeedbackInfoViewController) loader.getController();
            controller.initial(feedback, gridder);

            stage.setScene(scene);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
